#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: build_local.py 
@version:
@time: 2022/05/23 
"""
import time

from TapDevops.build_jenkins.build_base import BuildBase2
from TapDevops.build_jenkins.v2 import *


class BuildLocal(
    BuildBase2,
    V2LocalDataSourceSetting,
    V2LocalTaskCaseSetting,
    V2LocalMetaCaseSetting,
    V2LocalApiServerCaseSetting
):

    # 创建连接，加载schema
    def datasource_01(self):
        self.build(
            self.common_build(
                self.datasource_527_title,
                self.datasource_527
            )
        )

    # 创建task
    def task_01(self, _type='data_copy_initial'):
        title = ''
        path = ''
        if _type == 'data_copy_initial':
            title = self.title_data_copy_initial
            path = self.path_data_copy_initial
        elif _type == 'data_copy_cdc':
            title = self.title_data_copy_cdc
            path = self.path_data_copy_cdc
        elif _type == 'data_copy_initial_cdc':
            title = self.title_data_copy_initial_cdc
            path = self.path_data_copy_initial_cdc
        elif _type == 'data_development_initial':
            title = self.title_data_development_initial
            path = self.path_data_development_initial
        elif _type == 'data_development_cdc':
            title = self.title_data_development_cdc
            path = self.path_data_development_cdc
        elif _type == 'data_development_initial_cdc':
            title = self.title_data_development_initial_cdc
            path = self.path_data_development_initial_cdc
        data = self.common_build(
            title,
            path
        )
        self.build(
            data
        )

    # 创建task
    def task_02(self, _type='data_copy_initial'):
        title = ''
        path = ''
        if _type == 'data_copy_initial':
            title = self.title_data_copy_datatype_initial
            path = self.path_data_copy_datatype_initial
        elif _type == 'data_copy_cdc':
            title = self.title_data_copy_datatype_cdc
            path = self.path_data_copy_datatype_cdc
        elif _type == 'data_copy_initial_cdc':
            title = self.title_data_copy_datatype_initial_cdc
            path = self.path_data_copy_datatype_initial_cdc
        elif _type == 'data_development_initial':
            title = self.title_data_development_datatype_initial
            path = self.path_data_development_datatype_initial
        elif _type == 'data_development_cdc':
            title = self.title_data_development_datatype_cdc
            path = self.path_data_development_datatype_cdc
        elif _type == 'data_development_initial_cdc':
            title = self.title_data_development_datatype_initial_cdc
            path = self.path_data_development_datatype_initial_cdc
        data = self.common_build(
            title,
            path
        )
        self.build(
            data
        )

    # 数据校验 only for data copy, count
    def inspect_01(self, _type):
        title = ''
        path = ''
        if _type == 'data_inspect_initial':
            title = self.title_inspect_initial_count
            path = self.path_inspect_initial_count
        elif _type == 'data_inspect_cdc':
            title = self.title_inspect_cdc_count
            path = self.path_inspect_cdc_count
        elif _type == 'data_inspect_initial_cdc':
            title = self.title_inspect_initial_cdc_count
            path = self.path_inspect_initial_cdc_count
        data = self.common_build(
            title,
            path
        )
        self.build(
            data
        )

    # 数据校验 only for data copy, field
    def inspect_02(self, _type):
        title = ''
        path = ''
        if _type == 'data_inspect_initial':
            title = self.title_inspect_initial_field
            path = self.path_inspect_initial_field
        elif _type == 'data_inspect_cdc':
            title = self.title_inspect_cdc_field
            path = self.path_inspect_cdc_field
        elif _type == 'data_inspect_initial_cdc':
            title = self.title_inspect_initial_cdc_field
            path = self.path_inspect_initial_cdc_field
        data = self.common_build(
            title,
            path
        )
        self.build(
            data
        )

    # 数据校验 only for data copy, jointField
    def inspect_03(self, _type):
        title = ''
        path = ''
        if _type == 'data_inspect_initial':
            title = self.title_inspect_initial_jointField
            path = self.path_inspect_initial_jointField
        elif _type == 'data_inspect_cdc':
            title = self.title_inspect_cdc_jointField
            path = self.path_inspect_cdc_jointField
        elif _type == 'data_inspect_initial_cdc':
            title = self.title_inspect_initial_cdc_jointField
            path = self.path_inspect_initial_cdc_jointField
        data = self.common_build(
            title,
            path
        )
        self.build(
            data
        )

    # 共享挖掘
    def logminer(self):
        self.build(
            self.common_build(
                self.title_logminer,
                self.path_logminer
            )
        )

    # 数据发现
    def data_meta(self, _type):
        title = ''
        path = ''
        if _type == '1':
            title = self.title_data_catalogue_base
            path = self.path_data_catalogue_base
        elif _type == '2':
            title = self.title_data_catalogue_delete
            path = self.path_data_catalogue_delete
        elif _type == '3':
            title = self.title_data_catalogue_add_delete
            path = self.path_data_catalogue_add_delete
        elif _type == '4':
            title = self.title_data_search_table
            path = self.path_data_search_table
        elif _type == '5':
            title = self.title_data_search_patch
            path = self.path_data_search_patch
        elif _type == '6':
            title = self.title_data_search_column
            path = self.path_data_search_column
        data = self.common_build(
            title,
            path
        )
        self.build(
            data
        )

    # apiserver
    def api_server(self, _type):
        title = ''
        path = ''
        if _type == '1':
            title = self.title_api_server_query_1
            path = self.path_api_server_query_1
        elif _type == '2':
            title = self.title_api_server_query_2
            path = self.path_api_server_query_2
        elif _type == '3':
            title = self.title_api_server_exec_by_connector
            path = self.path_api_server_exec_by_connector
        elif _type == '3':
            title = self.title_api_server_exec_by_api
            path = self.path_api_server_exec_by_api
        data = self.common_build(
            title,
            path
        )
        self.build(
            data
        )
